home *** CD-ROM | disk | FTP | other *** search
- program EnvironmentTest; { Version 2.5 88/10/04
-
- Demonstrates ENVUNIT.PAS, handy little routines to simplify using the
- environment string.
-
- COMPILE TO _DISK_ AND RUN FROM INSIDE THE TURBO INTEGRATED ENVIRONMENT
- to simulate nested programs (ie. one program "exec"ed by another).
-
- This program is hereby donated to the public domain. It may be freely copied,
- used & modified without charge or fee.
-
- Author : Mike Babulic
- 3827 Charleswood Dr. N.W.
- Calgary, Alberta
- CANADA
- T2L 2C7
- Compuserve ID : 72307,314
-
- }
-
- uses CRT,Dos,EnvUnit;
-
- var SomeFile: string;
- oldPSP: word;
- i : integer;
-
- procedure Wait;
- begin
- write('Press Return');
- readln;
- GotoXY(WhereX,WhereY-1);
- ClrEol;
- end;
-
- procedure WriteEnvStrings;
- begin
- writeln;writeln(EnvCount,' Environment Strings...');
- writeln(' ',FirstEnv);
- while not EOEnv do
- writeln(' ',NextEnv);
- end;
-
- procedure PathSearch;
- begin
- writeln;
- writeln(' PathTo(''',somefile,''')...');
- writeln(' ',PathTo(somefile));
- writeln;
- writeln(' FFind(''',somefile,''')...');
- writeln(' ',FFind(somefile));
- wait;
- end;
-
- begin
- writeln;
- writeln('DOS Version ',Dos_Version/100.0:2:2);
- writeln;
- writeln('Program Path = ',MyPath);
- writeln(' Dir = ',MyDir );
- writeln(' Name = ',MyName);
- writeln(' Ext = ',MyExt );
- repeat
- oldPSP := PSP;
- UseParentPSP;
- if oldPSP <> PSP then begin
- writeln;
- writeln('Parent Name = ',ProgName);
- writeln(' Path = ',ProgPath);
- end;
- until oldPSP = PSP;
- writeln;
- writeln('Root PSP Reached.');
- writeln(' EnvSize = ',EnvSize,' bytes (max = ',MaxEnvSize,').');
- UseMyPSP;
- wait;
-
- writeln;
- writeln('Back to MyPSP.');
- writeln(' EnvSize = ',EnvSize,' bytes (max = ',MaxEnvSize,').');
- writeln;
- wait;
-
- WriteEnvStrings;
- wait;
-
- writeln;writeln('Using the EnvStr() function...');
- for i := 1 to EnvCount do
- writeln(i:3,') ',EnvStr(i));
- wait;
-
- somefile := 'COMSPEC';
- writeln;writeln('GetEnv(''',somefile,''')...');
- writeln(' ',GetEnv(somefile));
- wait;
-
- writeln;writeln('Named Strings...');
- writeln(' ',FirstNamed('PATH',';'));
- while not EONamed do
- writeln(' ',NextNamed);
- wait;
-
- writeln;writeln('Paths...');
- writeln(' ',FirstPath);
- while not EONamed do
- writeln(' ',NextPath);
- wait;
-
- SomeFile := '*.com';
- writeln;writeln('FSearch(''',somefile,''',GetEnv(''path''))...');
- writeln(' ',FSearch(somefile,GetEnv('path')));
- writeln;writeln('FExpand(''..''))...');
- writeln(' ',FExpand('..'));
- wait;
-
- writeln;writeln('AllowWildcards = ',AllowWildcards);
- PathSearch;
-
- AllowWildcards := FALSE;
- writeln;writeln('AllowWildcards = ',AllowWildcards);
- PathSearch;
-
- somefile := 'autoexec.bat';
- writeln;writeln('....but can still find files without wildcards.');
- PathSearch;
-
- somefile := 'c:\test';
- Writeln;writeln('SetPath(''',somefile,''') = ',
- SetPath(somefile));
-
- WriteEnvStrings;
- writeln;
- writeln('ProgPath = ',ProgPath);
- wait;
-
- writeln;writeln('SetPath('''') = ',SetPath(''));
- somefile := 'comspec';
- writeln;writeln('DelEnv(''',somefile,''')');
- DelEnv(somefile);
-
- WriteEnvStrings;
- writeln;
- writeln('ProgPath = ',ProgPath);
- wait;
- end.